package de.tudarmstadt.ukp.wikisniffer.userstudy.gui;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import de.tudarmstadt.ukp.wikisniffer.userstudy.Client;
import de.tudarmstadt.ukp.wikisniffer.userstudy.util.Answer;
import de.tudarmstadt.ukp.wikisniffer.userstudy.util.Question;

@SuppressWarnings("serial")
public abstract class AbstractQuestionGui extends AbstractGui {
	
	public abstract void init(Question question);
	
	protected abstract void startCounter();
	
	public void open(){
		this.setBounds(Client.bigScreen);
		this.setTitle(this.getClass().getSimpleName());
		this.setLayout(new BorderLayout(0,0));
		this.setAlwaysOnTop(true);
		TextArea tfWelcome = new TextArea(textFieldContent, 10, 50,  TextArea.SCROLLBARS_NONE);
		tfWelcome.setColumns(40);
		tfWelcome.setEditable(false);
		tfWelcome.setFont(new Font("Arial", Font.PLAIN, 18));
		this.add(tfWelcome, BorderLayout.NORTH);
		
		//add buttons
		this.add(getContentPanel(),BorderLayout.CENTER);
		
		this.setVisible(true);
		
		// add listener to detect window close button
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				//do nothing because participant should not be able to change test
				//Client.client.openStartGui(e);
			} 
		});
		
		//open questions
		Button bSubmit=new Button("Weiter");
		this.add(bSubmit,BorderLayout.EAST);
		bSubmit.addActionListener(
				new ActionListener(){
					public void actionPerformed(ActionEvent arg0) {
						Client.client.submitAnswer();
					}
				}
		);
		
		startCounter();
	}
	
	public abstract Answer getAnswer();

}
